package com.codemonkey.lq.qd.builder;

import com.codemonkey.lq.qd.facotry.config.SConfiguration;

/* 
 * 仿 Spring中的org.springframework.beans.factory.parsing.ReaderEventListener
 * 只提供一次机会,不提供多个listener的注册
 * 
 * 其实可以通过加入MixBuilderEventListener来接收多事件监听器,类似MyBatis中的MixedSqlNode(org.apache.ibatis.scripting.xmltags.MixedSqlNode)
 * 
 * 这里有个问题;因为我们是在基类中触发的事件,所以无法像Spring中的ReaderEventListener那样触发特定的事件;
 * 而只能让子类根据相应的BaseBuilder类型来自己判断
 * 
 * TODO 2017-01-26观看logback的源码,可以定义LifeCycle接口(Tomcat也是如此),框架发现有实现了该接口的类,就调用其start方法,这样也可以达到相同的目的.
 * */
//参见_thirdlibsLearing项目中的 spring.theory.event 包中的解释
public interface BuilderEventListener {
	
	
	
	
	/**
	 * fired after one service builded 
	 * @param sdBuilded
	 * @param sc
	 */
	//void serviceBuilded(ServiceDefinition sdBuilded,SConfiguration sc);
   
	/**
	 * fired after one action builded 
	 * @param adBuilded
	 * @param sc
	 */
	//void actionBuilded(ActionDefinition adBuilded,SConfiguration sc);
	
	/**
	 * fired after the entire config file build completely
	 * @param sc
	 */
	//void configurationBuilded(SConfiguration sc);
	
	
	
	/**
	 * fired  event after the element was builded
	 * 
	 * @param builder        :  XMLActionBuilder,XMLFlowBuilder,XMLServiceBuilder,XMLSConfigBuilder
	 * @param currentElement :  ActionDefinition,FlowDefinition,ServiceDefinition,SConfiguration
	 * @param sc 
	 */
	void builded(BaseBuilder builder,Object currentElement,SConfiguration sc);
}
